<?php
	$db = new CPDO();
	$sql = 'select * from `cc_cate`';
	$cates = $db->find($sql);
	
	$sql = 'select * from `cc_code`';
	$codes = $db->find($sql);
	foreach($codes as $code){
		$hive[$code->cate][] = $code;
	}
	$id = _g('i');
	$views = array();
	if($id){
		$sql = 'select * from `cc_code` where id = ' . $id;
		$views = $db->get($sql);
	}
	
?>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>ALIBABA 国际搜索 李春城 后台管理系统</title>
	<link rel="stylesheet" type="text/css" href="<?=BASEWWW?>/css/base.css" media="all">
	<link rel="stylesheet" type="text/css" href="<?=BASEWWW?>/css/styles/shCore.css" media="all">
	<link rel="stylesheet" type="text/css" href="<?=BASEWWW?>/css/styles/shThemeDefault.css" media="all">
</head>
<body>
<div id="navigation">
	<div id="search">
	  <input type="search" autocomplete="off" id="search-field" results="10" autosave="searchdoc" placeholder="Search" style="width: 253px;">
	</div>
	<ul id="results" style="height: 289px;"></ul><ul id="static-list" style="height: 289px;">

	<?foreach($cates as $cate):?>
		<li class="category"><span><?=$cate->cate_name?></span>
		<ul>
			<?foreach($hive[$cate->cate_name] as $item):?>
			<li class="sub">
				<a href="#<?=$item->id?>">
					<span class="searchable"><?=$item->title?></span>
					<span class="desc"><?=$item->desc?></span>
				</a>
			</li>
			<?endforeach?>
		 
		</ul>
	  </li>
	<?endforeach?>
</ul>


</div>
<div id="content">
<?if($views):?>
	<div class="entry-content">
	  <div class="entry-title">
		<h1><?=$views->title?> <a href="<?=BASEURL?>?a=add&i=<?=$views->id?>">编辑</a></h1>
	  </div>
	  <div class="entry">
		<h2> <?=$views->desc?></h2>
	  </div>
	</div>
	<?=htmlspecialchars_decode($views->content)?>
<?endif?>

</div>
<div id="footer" class="clearfix">		
	<p>Copyright © 2012</p>
	<p>alibaba-B2B-ICBU-国际搜索 李春城</p>
</div><!-- end of footer -->

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" src="<?=BASEWWW?>/javascript/hive.js"></script>
	<script type="text/javascript" src="<?=BASEWWW?>/javascript/highlight/scripts/shCore.js"></script>
	<script type="text/javascript" src="<?=BASEWWW?>/javascript/highlight/scripts/shBrushSql.js"></script>
	<script type="text/javascript" src="<?=BASEWWW?>/javascript/highlight/scripts/shBrushPython.js"></script>
	<script type="text/javascript" src="<?=BASEWWW?>/javascript/highlight/scripts/shBrushJScript.js"></script>
<script type="text/javascript">
     SyntaxHighlighter.all()
</script>

</body></html>
